/**
 * 
 */
package com.agilegroup.crm.adapters;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.agilegroup.crm.R;
import com.agilegroup.crm.model.BasicView;

/**
 * @author Hisham
 *
 */
public class SearchDialogAdapter  extends BaseAdapter{

	private Context context;
	private List<BasicView> basicViews;
	public SearchDialogAdapter(Context context, List<BasicView> basicViews) {
		this.basicViews=basicViews;
		this.context=context;
	}
	
	public int getCount() {
		return basicViews.size();
	}

	public Object getItem(int position) {
		return basicViews.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
        if (v == null)
        {
           LayoutInflater vi = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
           v = vi.inflate(R.layout.search_row, null);
           
           TextView id = (TextView)v.findViewById(R.id.txtid);
           TextView type = (TextView)v.findViewById(R.id.txtType);

           
           BasicView data = new BasicView();
           data=basicViews.get(position);
           id.setText(data.getId().toString());
           type.setText(data.getName()+" "+"{"+data.getType()+"}");
        }
        return v;
	}

}
